//
//  YSHistoryHeaderView.m
//  Yueshi
//
//  Created by Northwan on 15/8/12.
//  Copyright (c) 2015年 悦食中国. All rights reserved.
//

#import "YSHistoryHeaderView.h"
#import "YSCategoryHeaderView.h"
#import "YSHomeCardHeaderView.h"

@implementation YSHistoryHeaderView

-(instancetype)initWithResult:(YSHistoryRes *)result{
    self = [super init];
    if(self){
        YSHomeCardHeaderView *cardView = [YSHomeCardHeaderView headerView];
        [cardView setWidth:SCREENW];
        [cardView setX:0];
        [cardView setY:0];
        
        if(result.bannerList.count){
            YSCategoryHeaderView *bannerView = [[YSCategoryHeaderView alloc]init];
            [bannerView setBanner:result.bannerList];
            [bannerView setFrame:CGRectMake(0, 0, SCREENW, 250)];
            [self addSubview:bannerView];
            //
            [cardView setY:CGRectGetMaxY(bannerView.frame)];
        }
        
        YSHeaderResult *headerResult = [[YSHeaderResult alloc]init];
        [headerResult setCardIcon:result.cardBean.cardIcon];
        [headerResult setCardName:result.cardBean.cardName];
        [cardView setInfo:headerResult];
        [self addSubview:cardView];
        self.frame = CGRectMake(0, 0, SCREENW, CGRectGetMaxY(cardView.frame));
    }
    return self;
}

@end
